<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   主题：VC++中调用 R 的函数  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript">
   MathJax.Hub.Config({elements: ["bbpress-forums"]});
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://cos.name/cn/topic/9356/?new=1",
                  host: "http://cos.name",
                  prePath: "http://cos.name",
                  scheme: "http",
                  pathBase: "http://cos.name/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466444339: Accept with keywords: (title(0.5):主题,函数,C++,论坛, topn(0.233333333333):RSS订阅,软件应用,帖子,编译,R语言,会员,东风,拷贝到,文件,用户名,主站,种种原因,源代码,底层,高手,函数,项目,楼主,C++,问题,密码,普通,版主,本论坛,多项式,代码,主题,总计,论坛,讨论区).-->
 </head>
 <body class="topic bbpress single single-topic postid-9356 single-author sidebar" onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    主题：VC++中调用 R 的函数
   </h1>
  </div>
  <div class="container" id="xmain">
   <div class="hfeed site" id="page">
    <header class="site-header" id="masthead" role="banner">
     <div id="cos-logo">
      <a href="http://cos.name/cn">
       <img src="http://cos.name/cn/wp-content/themes/COS-forest/images/headers/cos-logo.png"/>
      </a>
     </div>
     <div class="navbar" id="navbar">
      <nav class="navigation main-navigation" id="site-navigation" role="navigation">
       <h3 class="menu-toggle">
        菜单
       </h3>
       <div class="menu-%e8%8f%9c%e5%8d%951-container">
        <ul class="nav-menu" id="menu-%e8%8f%9c%e5%8d%951">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-407772" id="menu-item-407772">
          <a href="http://cos.name/cn/">
           论坛首页
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-407773" id="menu-item-407773">
          <a href="http://cos.name/cn/forums/">
           讨论区
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-407774" id="menu-item-407774">
          <a href="http://cos.name/cn/wp-login.php?action=register">
           注册
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-407819" id="menu-item-407819">
          <a href="http://cos.name/">
           主站
          </a>
         </li>
        </ul>
       </div>
      </nav>
      <!-- #site-navigation -->
     </div>
     <!-- #navbar -->
    </header>
    <!-- #masthead -->
    <div class="site-main" id="main">
     <div class="content-area" id="primary">
      <div class="site-content" id="content" role="main">
       <article class="post-9356 topic type-topic status-publish hentry" id="post-9356">
        <header class="entry-header">
         <h1 class="entry-title">
          VC++中调用 R 的函数
         </h1>
        </header>
        <!-- .entry-header -->
        <div class="entry-content">
         <div id="bbpress-forums">
          <div class="bbp-breadcrumb">
           <p>
            <a class="bbp-breadcrumb-home" href="http://cos.name/cn/">
             COS论坛 | 统计之都
            </a>
            <span class="bbp-breadcrumb-sep">
             ›
            </span>
            <a class="bbp-breadcrumb-root" href="http://cos.name/cn/forums/">
             讨论区
            </a>
            <span class="bbp-breadcrumb-sep">
             ›
            </span>
            <a class="bbp-breadcrumb-forum" href="http://cos.name/cn/forum/software/">
             软件应用
            </a>
            <span class="bbp-breadcrumb-sep">
             ›
            </span>
            <a class="bbp-breadcrumb-forum" href="http://cos.name/cn/forum/software/r-language/">
             S-Plus &amp; R语言
            </a>
            <span class="bbp-breadcrumb-sep">
             ›
            </span>
            <span class="bbp-breadcrumb-current">
             VC++中调用 R 的函数
            </span>
           </p>
          </div>
          <div class="bbp-template-notice info">
           <p class="bbp-topic-description">
            该主题包含 103 条回复，82个帖子，最后由
            <a class="bbp-author-avatar" href="http://cos.name/cn/profile/yssacw/" rel="nofollow" title="查看yssacw的档案">
             <img src="http://sdn.geekzu.org/avatar/ece15d3c43515f76a0daec688f124837?s=14&amp;d=monsterid&amp;r=g"/>
            </a>
            <a class="bbp-author-name" href="http://cos.name/cn/profile/yssacw/" rel="nofollow" title="查看yssacw的档案">
             yssacw
            </a>
            在
            <a href="http://cos.name/cn/topic/9356/page/7/#post-410491" title="回复：VC++中调用 R 的函数">
             1 年, 3 月 之前
            </a>
            更新。
           </p>
          </div>
          <div class="bbp-pagination">
           <div class="bbp-pagination-count">
            查看 15 个帖子 - 1 到 15（总计 104 个）
           </div>
           <div class="bbp-pagination-links">
            <span class="page-numbers current">
             1
            </span>
            <a class="page-numbers" href="http://cos.name/cn/topic/9356/page/2/?new=1">
             2
            </a>
            <span class="page-numbers dots">
             …
            </span>
            <a class="page-numbers" href="http://cos.name/cn/topic/9356/page/7/?new=1">
             7
            </a>
            <a class="next page-numbers" href="http://cos.name/cn/topic/9356/page/2/?new=1">
             →
            </a>
           </div>
          </div>
          <ul class="forums bbp-replies" id="topic-9356-replies">
           <li class="bbp-header">
            <div class="bbp-reply-author">
             作者
            </div>
            <!-- .bbp-reply-author -->
            <div class="bbp-reply-content">
             帖子
            </div>
            <!-- .bbp-reply-content -->
           </li>
           <!-- .bbp-header -->
           <li class="bbp-body">
            <div class="bbp-reply-header" id="post-9356">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2008年1月10日 上午4:12
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/9356/#post-9356">
               1 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-9356 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-9356 bbp-reply-position-1 user-id-607 topic-author post-9356 topic type-topic status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/607/" rel="nofollow" title="查看raushon的档案">
               <img src="http://sdn.geekzu.org/avatar/41828141fbc00d623858d46e75582d27?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/607/" rel="nofollow" title="查看raushon的档案">
               raushon
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               需要在 VC++ 中调用R的函数。 按照R Manual — 《Writing R Extensions》的第6部分 ：
               <br/>
               The R API:entry points for Ccode 的说明， 编译总是通过不了。VC++代码如下：
              </p>
              <pre class="highlight ">#include &lt;R.h&gt;

void main()
{
  double *X;
  X = (double *) R_alloc(10, sizeof(double));
}
</pre>
              <p>
               编译出错：
               <br/>
               ——————–Configuration: callR – Win32 Debug——————–
               <br/>
               Compiling…
               <br/>
               callR.c
               <br/>
               Linking…
               <br/>
               callR.obj : error LNK2001: unresolved external symbol _R_alloc
               <br/>
               Debug/callR.exe : fatal error LNK1120: 1 unresolved externals
               <br/>
               Error executing link.exe.
               <br/>
               Creating browse info file…
              </p>
              <p>
               callR.exe – 2 error(s), 0 warning(s)
              </p>
              <p>
               VC++6.0的编译环境 和 链接库 (Tools | Options | Directories | include…)的设置似乎是没有问题的。
              </p>
              <p>
               这应该是动态链接库的问题，但是我实在是 不知道该怎么解决，把R.dll拷贝到Debug目录下也是不行。
              </p>
              <p>
               我的R是2.50RC版本的，各位大虾帮帮忙看如何解决C++调用R的问题，谢谢了！
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-241643">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2008年1月13日 上午8:15
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/9356/#post-241643">
               2 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-241643 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-9356 bbp-reply-position-2 user-id-607 topic-author post-241643 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/607/" rel="nofollow" title="查看raushon的档案">
               <img src="http://sdn.geekzu.org/avatar/41828141fbc00d623858d46e75582d27?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/607/" rel="nofollow" title="查看raushon的档案">
               raushon
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               请问，这里有熟悉VC++的达人，能否帮忙解决这个问题噢
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-241651">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2008年1月13日 上午9:59
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/9356/#post-241651">
               3 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-241651 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-9356 bbp-reply-position-3 user-id-28760 post-241651 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/28760/" rel="nofollow" title="查看陈放的档案">
               <img src="http://sdn.geekzu.org/avatar/df21449fd3d277683d7e3dfd7557259b?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/28760/" rel="nofollow" title="查看陈放的档案">
               陈放
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               我对这个问题也有兴趣，李东风有一个关于R与C的短文，在本论坛有你先看看，是用borland C。搞好给我说一声，我的emails：chenfang11@emails.bjut.edu.cn 可惜我试几次都没有成功，我不知怎样建立dll文件。
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-241681">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2008年1月14日 上午12:44
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/9356/#post-241681">
               4 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-241681 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-9356 bbp-reply-position-4 user-id-7484 post-241681 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/7484/" rel="nofollow" title="查看karlqi的档案">
               <img src="http://sdn.geekzu.org/avatar/f5edfdb127d930ad1ca1450a7654dfb6?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/7484/" rel="nofollow" title="查看karlqi的档案">
               karlqi
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               R是开源的，其内核的实现函数无非是C++ codes或是Fortan codes。
               <br/>
               在开发VC++项目时，如果只想用某几个特定的R函数(该函数又不依赖于其他底层函数或仅仅只依赖几个底层函数)的话，与其在VC++中调用R函数，还不如直接提取C++ codes，或者提取由Fortan codes转换而来C++ codes，直接嵌入到你自己的VC++项目中。如果出于种种原因非要调用，当然也是可以的，无非就是把R调用其自己的底层.c .f 文件的过程(通过R API)再重复一遍而已。所以在楼主提到的文献Writing R Extensions中并不是说“using VC++ to call R function”而是说“R API:entry points for C code”(R的API函数:C code的入口点)，这两者是不同的。说道底，你调用的只是R function底下的C codes。是C调C而不是C调R,唯一不同是后一种方法不用为底层函数的依赖关系操心了；不过话说回来，谁都不愿意开发一个自己的VC++项目还非要人家装个R不可。所以玩玩可以，实际不推荐楼主的做法。
               <br/>
               如果还要坚持做，做法比较繁琐了，首先得下载Rtools，用make.exe把Rmath.dll等文件重新编译出来，后面的事帮助里说的很清楚了，不多啰嗦了。
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-241789">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2008年1月15日 上午4:51
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/9356/#post-241789">
               5 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-241789 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-9356 bbp-reply-position-5 user-id-607 topic-author post-241789 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/607/" rel="nofollow" title="查看raushon的档案">
               <img src="http://sdn.geekzu.org/avatar/41828141fbc00d623858d46e75582d27?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/607/" rel="nofollow" title="查看raushon的档案">
               raushon
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <blockquote class="d4pbbc-quote">
               <p>
                [b]引用第3楼[i]karlqi[/i]于[i]2008-01-14 08:44[/i]发表的“”[/b]:
               </p>
               <p>
                在开发VC++项目时，如果只想用某几个特定的R函数(该函数又不依赖于其他底层函数或仅仅只依赖几个底层函数)的话，与其在VC++中调用R函数，还不如直接提取C++ codes，或者提取由Fortan codes转换而来C++ codes，直接嵌入到你自己的VC++项目中。如果出于种种原因非要调用，当然也是可以的，无非就是把R调用其自己的底层.c .f 文件的过程(通过R API)再重复一遍而已。
                <br/>
                。。。。。。。。。。。。。。。。
                <br/>
                如果还要坚持做，做法比较繁琐了，首先得下载Rtools，用make.exe把Rmath.dll等文件重新编译出来，后面的事帮助里说的很清楚了，不多啰嗦了。
               </p>
              </blockquote>
              <p>
               首先非常感激这位仁兄提供的帮助！
              </p>
              <p>
               由于本人开发的系统是在VC++工程中进行的，现在需要调用R 中的multinom(nnet) ( nnet 包中 函数 ) ， 用VC++编一个多项式 Logit模型 暂时估计不现实，所以想在VC中直接调用它。
              </p>
              <p>
               你所提到的从R中直接提取C++ codes的方法当然很好了，但是我不知道如何提？ 能详细一点讲讲如何把multinom()函数的C++代码提取出来吗 ？
              </p>
              <p>
               谢谢！
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-241798">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2008年1月15日 上午7:08
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/9356/#post-241798">
               6 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-241798 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-9356 bbp-reply-position-6 user-id-7484 post-241798 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/7484/" rel="nofollow" title="查看karlqi的档案">
               <img src="http://sdn.geekzu.org/avatar/f5edfdb127d930ad1ca1450a7654dfb6?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/7484/" rel="nofollow" title="查看karlqi的档案">
               karlqi
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               这个我已经实现了，部分代码如下，明眼人一看就清楚了。当然了，提取时不要忘记提取底层函数和一些个全局变量定义。
               <br/>
               p.s.:怎么找相关函数？在R下用UltraEdit搜一下，轻松搞定！代码比较长，就隐藏了，想看的回复下就好了，不然这么多行的代码很晕的呢，隐了吧。
              </p>
              <p>
               //////////////////////////RNG.h/////////////////////////////////////
              </p>
              <p>
               #defined(RNG_EXPORTS)
               <br/>
               #define RNG_API __declspec(dllexport)
               <br/>
               #else
               <br/>
               #define RNG_API __declspec(dllimport)
               <br/>
               #endif
              </p>
              <p>
               #ifdef __cplusplus
               <br/>
               extern "C" {
               <br/>
               #endif
              </p>
              <p>
               <strong class="d4pbbc-bold">
                RNG_API void __stdcall rmultinom(long* n, double* prob, long* size, long* K, long* randomNum);
               </strong>
               <br/>
               #ifdef __cplusplus
               <br/>
               }
               <br/>
               #endif
              </p>
              <p>
               //////////////////////////RNG.cpp/////////////////////////////////////
               <br/>
               #include "RNG.h"
               <br/>
               …
              </p>
              <p>
               <strong class="d4pbbc-bold">
                void __stdcall rmultinom(long* n, double* prob, long* size, long* K, long* randomNum)
               </strong>
               <br/>
               {
               <br/>
               <br/>
               long* rN = randomNum;
               <br/>
               for(long i = 0; i &lt; n[0]; i++)
               <br/>
               {
               <br/>
               __rmultinom(size[0], prob, K[0], rN);
               <br/>
               for(long j = 0; j &lt; K[0]; j++){
               <br/>
               randomNum[i*K[0]+j] = rN[j];
               <br/>
               }
               <br/>
               }
               <br/>
               return;
              </p>
              <p>
               }
              </p>
              <p>
               ///以下来自R package：
              </p>
              <p>
               <strong class="d4pbbc-bold">
                void __rmultinom(long n, double* prob, long K, long* rN)
               </strong>
               <br/>
               {
               <br/>
               long k;
               <br/>
               double pp, p_tot = 0.;
              </p>
              <p>
               for(k = 0; k &lt; K; k++) {
               <br/>
               pp = prob[k];
               <br/>
               p_tot += pp;
               <br/>
               rN[k] = 0;
               <br/>
               }
               <br/>
               if (n == 0) return;
               <br/>
               if (K == 1 &amp;&amp; p_tot == 0.) return;
              </p>
              <p>
               for(k = 0; k &lt; K-1; k++) {
               <br/>
               if(prob[k]) {
               <br/>
               pp = prob[k] / p_tot;
               <br/>
               rN[k] = ((pp &lt; 1.) ? (long) __rbinom((double) n, pp) :   n);
               <br/>
               n -= rN[k];
               <br/>
               }
               <br/>
               else rN[k] = 0;
               <br/>
               if(n &lt;= 0) return;
               <br/>
               p_tot -= prob[k];
               <br/>
               }
               <br/>
               rN[K-1] = n;
               <br/>
               return;
               <br/>
               }
              </p>
              <p>
               ///以下代码来自R
               <br/>
               <strong class="d4pbbc-bold">
                long __rbinom(double nin, double pp)
               </strong>
               <br/>
               {
               <br/>
               static double c, fm, npq, p1, p2, p3, p4, qn;
               <br/>
               static double xl, xll, xlr, xm, xr;
              </p>
              <p>
               static double psave = -1.0;
               <br/>
               static long nsave = -1;
               <br/>
               static long m;
              </p>
              <p>
               double f, f1, f2, u, v, w, w2, x, x1, x2, z, z2;
               <br/>
               double p, q, np, g, r, al, alv, amaxp, ffm, ynorm;
               <br/>
               long i,ix,k,n;
              </p>
              <p>
               n = (long)floor(nin + 0.5);
               <br/>
               <br/>
               if (n == 0 || pp == 0.) return 0;
               <br/>
               if (pp == 1.) return n;
              </p>
              <p>
               p = fmin2(pp, 1. – pp);
               <br/>
               q = 1. – p;
               <br/>
               np = n * p;
               <br/>
               r = p / q;
               <br/>
               g = r * (n + 1);
              </p>
              <p>
               /* Setup, perform only when parameters change [using static (globals): */
              </p>
              <p>
               /* FIXING: Want this thread safe
               <br/>
               — use as little (thread globals) as possible
               <br/>
               */
               <br/>
               if (pp != psave || n != nsave) {
               <br/>
               psave = pp;
               <br/>
               nsave = n;
               <br/>
               if (np &lt; 30.0) {
               <br/>
               /* inverse cdf logic for mean less than 30 */
               <br/>
               qn = pow(q, (double) n);
               <br/>
               goto L_np_small;
               <br/>
               } else {
               <br/>
               ffm = np + p;
               <br/>
               m = (long)ffm;
               <br/>
               fm = m;
               <br/>
               npq = np * q;
               <br/>
               p1 = (long)(2.195 * sqrt(npq) – 4.6 * q) + 0.5;
               <br/>
               xm = fm + 0.5;
               <br/>
               xl = xm – p1;
               <br/>
               xr = xm + p1;
               <br/>
               c = 0.134 + 20.5 / (15.3 + fm);
               <br/>
               al = (ffm – xl) / (ffm – xl * p);
               <br/>
               xll = al * (1.0 + 0.5 * al);
               <br/>
               al = (xr – ffm) / (xr * q);
               <br/>
               xlr = al * (1.0 + 0.5 * al);
               <br/>
               p2 = p1 * (1.0 + c + c);
               <br/>
               p3 = p2 + c / xll;
               <br/>
               p4 = p3 + c / xlr;
               <br/>
               }
               <br/>
               } else if (n == nsave) {
               <br/>
               if (np &lt; 30.0)
               <br/>
               goto L_np_small;
               <br/>
               }
              </p>
              <p>
               /*————————– np = n*p &gt;= 30 : ——————- */
               <br/>
               repeat {
               <br/>
               u = unif_rand() * p4;
               <br/>
               v = unif_rand();
               <br/>
               /* triangular region */
               <br/>
               if (u &lt;= p1) {
               <br/>
               ix = (long)(xm – p1 * v + u);
               <br/>
               goto finis;
               <br/>
               }
               <br/>
               /* parallelogram region */
               <br/>
               if (u &lt;= p2) {
               <br/>
               x = xl + (u – p1) / c;
               <br/>
               v = v * c + 1.0 – fabs(xm – x) / p1;
               <br/>
               if (v &gt; 1.0 || v &lt;= 0.)
               <br/>
               continue;
               <br/>
               ix = (long)x;
               <br/>
               } else {
               <br/>
               if (u &gt; p3) {   /* right tail */
               <br/>
               ix = (long)(xr – log(v) / xlr);
               <br/>
               if (ix &gt; n)
               <br/>
               continue;
               <br/>
               v = v * (u – p3) * xlr;
               <br/>
               } else {/* left tail */
               <br/>
               ix = (long)(xl + log(v) / xll);
               <br/>
               if (ix &lt; 0)
               <br/>
               continue;
               <br/>
               v = v * (u – p2) * xll;
               <br/>
               }
               <br/>
               }
               <br/>
               /* determine appropriate way to perform accept/reject test */
               <br/>
               k = abs(ix – m);
               <br/>
               if (k &lt;= 20 || k &gt;= npq / 2 – 1) {
               <br/>
               /* explicit evaluation */
               <br/>
               f = 1.0;
               <br/>
               if (m &lt; ix) {
               <br/>
               for (i = m + 1; i &lt;= ix; i++)
               <br/>
               f *= (g / i – r);
               <br/>
               } else if (m != ix) {
               <br/>
               for (i = ix + 1; i &lt;= m; i++)
               <br/>
               f /= (g / i – r);
               <br/>
               }
               <br/>
               if (v &lt;= f)
               <br/>
               goto finis;
               <br/>
               } else {
               <br/>
               /* squeezing using upper and lower bounds on log(f(x)) */
               <br/>
               amaxp = (k / npq) * ((k * (k / 3. + 0.625) + 0.1666666666666) / npq + 0.5);
               <br/>
               ynorm = -k * k / (2.0 * npq);
               <br/>
               alv = log(v);
               <br/>
               if (alv &lt; ynorm – amaxp)
               <br/>
               goto finis;
               <br/>
               if (alv &lt;= ynorm + amaxp) {
               <br/>
               /* stirling's formula to machine accuracy */
               <br/>
               /* for the final acceptance/rejection test */
               <br/>
               x1 = ix + 1;
               <br/>
               f1 = fm + 1.0;
               <br/>
               z = n + 1 – fm;
               <br/>
               w = n – ix + 1.0;
               <br/>
               z2 = z * z;
               <br/>
               x2 = x1 * x1;
               <br/>
               f2 = f1 * f1;
               <br/>
               w2 = w * w;
               <br/>
               if (alv &lt;= xm * log(f1 / x1) + (n – m + 0.5) * log(z / w) + (ix – m) * log(w * p / (x1 * q)) + (13860.0 – (462.0 – (132.0 – (99.0 – 140.0 / f2) / f2) / f2) / f2) / f1 / 166320.0 + (13860.0 – (462.0 – (132.0 – (99.0 – 140.0 / z2) / z2) / z2) / z2) / z / 166320.0 + (13860.0 – (462.0 – (132.0 – (99.0 – 140.0 / x2) / x2) / x2) / x2) / x1 / 166320.0 + (13860.0 – (462.0 – (132.0 – (99.0 – 140.0 / w2) / w2) / w2) / w2) / w / 166320.)
               <br/>
               goto finis;
               <br/>
               }
               <br/>
               }
               <br/>
               }
              </p>
              <p>
               L_np_small:
               <br/>
               /*———————- np = n*p &lt; 30 : ————————- */
              </p>
              <p>
               repeat {
               <br/>
               ix = 0;
               <br/>
               f = qn;
               <br/>
               u = unif_rand();
               <br/>
               repeat {
               <br/>
               if (u &lt; f)
               <br/>
               goto finis;
               <br/>
               if (ix &gt; 110)
               <br/>
               break;
               <br/>
               u -= f;
               <br/>
               ix++;
               <br/>
               f *= (g / ix – r);
               <br/>
               }
               <br/>
               }
              </p>
              <p>
               finis:
               <br/>
               if (psave &gt; 0.5)
               <br/>
               ix = n – ix;
               <br/>
               return ix;
               <br/>
               }
              </p>
              <p>
               加油！加油！
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-241803">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2008年1月15日 上午7:28
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/9356/#post-241803">
               7 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-241803 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-9356 bbp-reply-position-7 user-id-607 topic-author post-241803 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/607/" rel="nofollow" title="查看raushon的档案">
               <img src="http://sdn.geekzu.org/avatar/41828141fbc00d623858d46e75582d27?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/607/" rel="nofollow" title="查看raushon的档案">
               raushon
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               感激不尽
               <br/>
               我试试看吧
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-241843">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2008年1月15日 下午2:49
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/9356/#post-241843">
               8 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-241843 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-9356 bbp-reply-position-8 user-id-13813 post-241843 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/13813/" rel="nofollow" title="查看flashcrazy的档案">
               <img src="http://sdn.geekzu.org/avatar/37d03ccd9e4ab994633f0b1983b320ca?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/13813/" rel="nofollow" title="查看flashcrazy的档案">
               flashcrazy
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               看看  ，高手真多啊
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-241845">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2008年1月15日 下午3:22
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/9356/#post-241845">
               9 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-241845 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-9356 bbp-reply-position-9 user-id-28760 post-241845 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/28760/" rel="nofollow" title="查看陈放的档案">
               <img src="http://sdn.geekzu.org/avatar/df21449fd3d277683d7e3dfd7557259b?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/28760/" rel="nofollow" title="查看陈放的档案">
               陈放
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               真的是高手，其实用c调用R没有太大意思。用r调用c里面，这样就像李东风老师说那样可以使r的速度提高。也就克服了r的劣势。
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-241859">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2008年1月16日 上午2:04
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/9356/#post-241859">
               10 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-241859 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-9356 bbp-reply-position-10 user-id-123 post-241859 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/123/" rel="nofollow" title="查看abel的档案">
               <img src="http://sdn.geekzu.org/avatar/60dea4c8a3f2115785ea7668a3654b2d?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/123/" rel="nofollow" title="查看abel的档案">
               abel
              </a>
              <br/>
              <div class="bbp-author-role">
               版主
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               good
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-241863">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2008年1月16日 上午4:17
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/9356/#post-241863">
               11 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-241863 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-9356 bbp-reply-position-11 user-id-607 topic-author post-241863 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/607/" rel="nofollow" title="查看raushon的档案">
               <img src="http://sdn.geekzu.org/avatar/41828141fbc00d623858d46e75582d27?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/607/" rel="nofollow" title="查看raushon的档案">
               raushon
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               karlqi你好，
               <br/>
               能否解释下 rmultinom(long* n, double* prob, long* size, long* K, long* randomNum)
               <br/>
               里面的各个参数的意义吗？
              </p>
              <p>
               谢谢！
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-241869">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2008年1月16日 上午6:02
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/9356/#post-241869">
               12 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-241869 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-9356 bbp-reply-position-12 user-id-7484 post-241869 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/7484/" rel="nofollow" title="查看karlqi的档案">
               <img src="http://sdn.geekzu.org/avatar/f5edfdb127d930ad1ca1450a7654dfb6?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/7484/" rel="nofollow" title="查看karlqi的档案">
               karlqi
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               从rbinom(n, size, prob)就可以看出rmultinom(n, prob, size, K)的意思啦，至于randomNum是用来放结果的。
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-241879">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2008年1月16日 上午7:20
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/9356/#post-241879">
               13 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-241879 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-9356 bbp-reply-position-13 user-id-607 topic-author post-241879 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/607/" rel="nofollow" title="查看raushon的档案">
               <img src="http://sdn.geekzu.org/avatar/41828141fbc00d623858d46e75582d27?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/607/" rel="nofollow" title="查看raushon的档案">
               raushon
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               这种方式是可以在VC中实现rmultinom()函数功能，这是个实现满足多项式分布的函数
               <br/>
               而我想要调用的函数是multinom()  是‘nnet’ package 下的可以用于分类预测的函数
               <br/>
               R中没有它的C++代码， 只有R源代码， VC 能直接通过R提供的接口调用吗？
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-241883">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2008年1月16日 上午7:48
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/9356/#post-241883">
               14 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-241883 -->
            <div class="even bbp-parent-forum-999 bbp-parent-topic-9356 bbp-reply-position-14 user-id-7484 post-241883 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/7484/" rel="nofollow" title="查看karlqi的档案">
               <img src="http://sdn.geekzu.org/avatar/f5edfdb127d930ad1ca1450a7654dfb6?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/7484/" rel="nofollow" title="查看karlqi的档案">
               karlqi
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               那个"nnet"包也有源代码的啊,去CRAN下载啊，一样提取。
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
            <div class="bbp-reply-header" id="post-241952">
             <div class="bbp-meta">
              <span class="bbp-reply-post-date">
               2008年1月17日 上午7:01
              </span>
              <a class="bbp-reply-permalink" href="http://cos.name/cn/topic/9356/#post-241952">
               15 楼
              </a>
              <span class="bbp-admin-links">
              </span>
             </div>
             <!-- .bbp-meta -->
            </div>
            <!-- #post-241952 -->
            <div class="odd bbp-parent-forum-999 bbp-parent-topic-9356 bbp-reply-position-15 user-id-789 post-241952 reply type-reply status-publish hentry">
             <div class="bbp-reply-author">
              <a class="bbp-author-avatar" href="http://cos.name/cn/profile/789/" rel="nofollow" title="查看mmx-plus的档案">
               <img src="http://sdn.geekzu.org/avatar/9b5d9747f6a11937df1a9a164db55d0b?s=80&amp;d=monsterid&amp;r=g"/>
              </a>
              <br/>
              <a class="bbp-author-name" href="http://cos.name/cn/profile/789/" rel="nofollow" title="查看mmx-plus的档案">
               mmx-plus
              </a>
              <br/>
              <div class="bbp-author-role">
               普通会员
              </div>
             </div>
             <!-- .bbp-reply-author -->
             <div class="bbp-reply-content">
              <p>
               高人  ！学到一招！
              </p>
             </div>
             <!-- .bbp-reply-content -->
            </div>
            <!-- .reply -->
           </li>
           <!-- .bbp-body -->
           <li class="bbp-footer">
            <div class="bbp-reply-author">
             作者
            </div>
            <div class="bbp-reply-content">
             帖子
            </div>
            <!-- .bbp-reply-content -->
           </li>
           <!-- .bbp-footer -->
          </ul>
          <!-- #topic-9356-replies -->
          <div class="bbp-pagination">
           <div class="bbp-pagination-count">
            查看 15 个帖子 - 1 到 15（总计 104 个）
           </div>
           <div class="bbp-pagination-links">
            <span class="page-numbers current">
             1
            </span>
            <a class="page-numbers" href="http://cos.name/cn/topic/9356/page/2/?new=1">
             2
            </a>
            <span class="page-numbers dots">
             …
            </span>
            <a class="page-numbers" href="http://cos.name/cn/topic/9356/page/7/?new=1">
             7
            </a>
            <a class="next page-numbers" href="http://cos.name/cn/topic/9356/page/2/?new=1">
             →
            </a>
           </div>
          </div>
          <div class="bbp-no-reply" id="no-reply-9356">
           <div class="bbp-template-notice">
            <p>
             您必须先登录才能回复该主题。
            </p>
           </div>
          </div>
         </div>
        </div>
        <!-- .entry-content -->
        <footer class="entry-meta">
        </footer>
        <!-- .entry-meta -->
       </article>
       <!-- #post -->
       <div class="comments-area" id="comments">
       </div>
       <!-- #comments -->
      </div>
      <!-- #content -->
     </div>
     <!-- #primary -->
     <div class="sidebar-container" id="tertiary" role="complementary">
      <div class="sidebar-inner">
       <div class="widget-area">
        <aside class="widget bbp_widget_login" id="bbp_login_widget-2">
         <h3 class="widget-title">
          登录
         </h3>
         <form action="http://cos.name/cn/wp-login.php" class="bbp-login-form" method="post">
          <fieldset>
           <legend>
            登录
           </legend>
           <div class="bbp-username">
            <label for="user_login">
             用户名:
            </label>
           </div>
           <div class="bbp-password">
            <label for="user_pass">
             密码:
            </label>
           </div>
           <div class="bbp-remember-me">
            <label for="rememberme">
             记住用户名
            </label>
           </div>
           <div class="bbp-submit-wrapper">
            <button class="button submit user-submit" id="user-submit" name="user-submit" tabindex="104" type="submit">
             登录
            </button>
           </div>
           <div class="bbp-login-links">
            <a class="bbp-register-link" href="http://cos.name/cn/wp-login.php?action=register" title="注册">
             注册
            </a>
            <a class="bbp-lostpass-link" href="http://cos.name/cn/wp-login.php?action=lostpassword" title="忘记密码">
             忘记密码
            </a>
           </div>
          </fieldset>
         </form>
        </aside>
        <aside class="widget widget_text" id="text-7">
         <h3 class="widget-title">
          搜索
         </h3>
         <div class="textwidget">
          <form action="http://www.google.com/search" id="bbp-search-form" method="get" onsubmit="Gsitesearch(this)" role="search">
           <div>
           </div>
          </form>
          <form id="bbp-search-form-baidu" onsubmit="g(this)" role="search">
           <div>
           </div>
          </form>
         </div>
        </aside>
        <aside class="widget widget_text" id="text-2">
         <h3 class="widget-title">
          新鲜事
         </h3>
         <div class="textwidget">
          <ul>
           <li>
            <a href="http://cos.name/cn/topics/">
             最新帖子
            </a>
           </li>
           <li>
            <a href="http://cos.name/cn/view/popular/">
             最热门主题
            </a>
           </li>
           <li>
            <a href="http://cos.name/cn/view/no-replies/">
             消灭零回复
            </a>
           </li>
          </ul>
         </div>
        </aside>
        <aside class="widget widget_text" id="text-3">
         <h3 class="widget-title">
          RSS订阅
         </h3>
         <div class="textwidget">
          <ul>
           <li>
            <img src="http://cos.name/wp-includes/images/rss.png"/>
            <a href="http://cos.name/cn/topics/feed/">
             所有主题
            </a>
           </li>
           <li>
            <img src="http://cos.name/wp-includes/images/rss.png"/>
            <a href="http://cos.name/cn/forums/feed/">
             所有帖子
            </a>
           </li>
          </ul>
         </div>
        </aside>
       </div>
       <!-- .widget-area -->
      </div>
      <!-- .sidebar-inner -->
     </div>
     <!-- #tertiary -->
    </div>
    <!-- #main -->
    <footer class="site-footer" id="colophon" role="contentinfo">
     <div class="site-info">
      版权所有 © 2014 统计之都 | 由
      <a href="http://wordpress.org/">
       WordPress
      </a>
      构建 | 主题修改自
      <a href="http://wordpress.org/themes/twentythirteen">
       Twenty Thirteen
      </a>
     </div>
     <!-- .site-info -->
    </footer>
    <!-- #colophon -->
   </div>
   <!-- #page -->
  </div>
 </body>
</html>